Do you put on weight if you eat more but exercise more?

It would depend. On how much eating versus how much exercise.
Eat & Exercise. Not necessarily. If you burn off all the calories you take in, you shouldn't gain weight. Pro athletes can expend 10, 000 calories a day so they can eat 10, 000 calories and don't gain weight. If your exercise includes weight lifting, you may gain muscle mass and therefore gain weight.
What you eat matters. It is not simply a matter of calories in, calories out. What you eat matters. If you eat a lot of sugar and starch, you will be prone to store fat. If you eat mostly protein and vegetables, you will be prone to burn fat. What you eat matters very much!