The real answer here is incredibly broad, but boils down to discipline and respect. Bringing a child up with consistent discipline means they know when to play and when to sit still; When to be active and when to be quiet. For those times they don't know, respect means they will listen to you and do as you guide/tell them.
In order to get this level of discipline and respect you need to spend a lot of time with your child - they learn this by example and consistency - so once you have rules, you need to stick to them (as does your partner) because confusion in rules just confuses children, and they then will misbehave (deliberately or not) especially when tired, or stressed, as they may be during travel. At 2 you may think they are too young to understand rules, but they really aren't - they will be picking up on cues since they were much younger than this.
And for those occasions when it just doesn't work (being a realist here) have something interesting to do - have an interesting book you can read to your child, or have some crayons, or a snack, or anything they haven't seen before. Don't go to sleep or ignore your child - they only have short attention spans at that age.
I can vouch that this has worked on various long haul flights with my 3 kids - from ages of around 20 months upwards, but obviously your mileage may vary: I have always been a chilled out world traveller, so the stress levels in my family when travelling are pretty low :-)