In general, train schedules can be found
here
1. Barcelona to Madrid takes 2:45 by
AVE (high speed train). Alternatively you can fly.
Vienna to Prague takes about 4.5 hrs. Normal EuroCity (many trains/day) or SuperCity Pendolino (1 train/day).
If the flight is cheap, go for it (I'd say a total 4 hrs travel time incl. to/from airport). Otherwise, go by train.
Budapest=>vienna is 3 hrs by train
2. Look at who flies between these airports (on wikipedia) and check LCC websites.
Skyscanner also works. Cheaptickets does not include many low cost carriers.
3. Book plane tix ASAP, especially on low-cost carrier flights.
4. No need to, except on high speed trains. Book BCN=>MAD now if you can. Renfe can be a bit glitchy.