Is it best to attack the flat before a hill?
NO
On flat ground, power is proportional to speed cubed because drag from air dominates. If you want to go twice as fast on flat ground, you need to expend eight times the power. So if you're going 20 mph/30 kph and double your power, you'll wind up going all of 25 mph/38 kph - and you'll blow yourself up really fast if you were riding close to your threshold power to begin with.
But on a steep enough hill where overcoming gravity dominates over drag, then when you double your power, you'll go twice as fast up the hill.
Lets say you're going 30 kph at 200W on the flats, and that's a power you can hold for good long while, but you can hold 400W for two minutes. Let's be generous and say 400W on flat ground gets you up to 40 kph. You'll cover 1 1/3 km in those two minutes - then lets say you can still hold 200W (you won't, though...) and it takes you four minutes to climb a short, steep hill at 200W. That's a total of 6 minutes to get to the top of the hill.
And I was really generous at how much faster doubling your power on the flats improves your speed and in assuming you'd be able to climb that hill at 200W after blowing yourself out on the flat...
OK, let's turn power outputs around. At 200W and 30 kph, covering that 1 1/3 km will take 2 minutes and 40 sec. But now you get to go up that hill at 400W and only take 2 minutes.
You're at the top of the climb in 4 minutes and 40 seconds - you just dropped the you that blew yourself up on the flat, getting yourself a minute and 20 second lead.
And you get to recover on the descent.
Heck, take it a bit easy up the hill at 350W, you only got a minute lead, but spent a lot less energy, saving it for later climbs or sprints.
You can spend less energy and go faster if you spend that energy where it gets you the most velocity.