I want to amplify a 4 MHz triangle or square wave by 2 using an op-amp. Do I need an ~8 MHz op amp, or a much higher rated (and more expensive) device to handle the harmonics?
Short Answer- Yes. Minimum 3x the fundamental frequency for triangle and 5x for square wave. (9x gets you pretty good, low ripple answer for both)
Long Answer. Both of these waveforms are the sum of multiple sine waves. To get a reasonable (and your definition of this may vary) quality square wave, you need at least the first 5 or 6 harmonics (1x,3x,5x,7x,9x, and 11x multiples of the fundamental). If your opamp doesn't pass these frequencies, then you'll get distortion in the output.
The links below will show you how to build up triangle and square waves mathematically if you want to see for yourself how much fidelity you get for a given bandwidth.
To perfectly amplify a square wave, you'll need an op-amp with infinite bandwidth.
What is the square wave used for? You probably don't need to keep all of those harmonics.
You'll need at least 3x for a square wave.