Which engineering branch will be most suitable for becoming an astronaut, and what other options do I have if I want to become an astronaut with an engineering background?
I thought it might be interesting (and hopefully helpful) to take a look at the education that astronauts actually have. For that, I decided to look at the list of current NASA astronauts (and current but not flight-eligible), and former NASA astronauts (there are some extremely interesting people in there, by the way).
For the sake of this answer, I'm going to simplify a few things and lump similar degrees together. In some of these instances degrees have similar, but different, names. They seem to be similar enough for the purpose of this answer, and it'll make this easier to write and read if I list them together. Because this question is specifically asking about engineering I'm also going to leave out anything that isn't related to engineering, unless it came up a lot and I think it's interesting. I'm also excluding any honorary degrees, and I tried to include only degrees earned before the astronaut's career began because anything following that seemed less relevant to becoming an astronaut (not guaranteeing perfection here, though). Only the highest degrees earned by each astronaut made it into my list.
Current astronauts (including those ineligible for flight): Of the current astronauts, five of them have earned Bachelor degrees, 43 have earned Master degrees, and 31 have earned a Doctorate.
Of the Bachelor degrees, one is a Civil Engineering degree, and two are Aerospace Engineering degrees. The only other two are in Mathematics. It seems that, for the most part at least, astronauts with only a Bachelor degree also had successful military careers. Most astronauts have earned at least a Master degree.
The most common Master degrees seem to be in Aerospace Engineering (including Aeronautics and/or Astronautics). Here is a list:
Aerospace Engineering: 16
Electrical Engineering: 4
Mechanical Engineering: 3
Ocean Engineering: 2
Systems Engineering: 2
Flight Test Engineering: 1
Industrial Engineering: 1
Engineering Management: 1
The rest of the Master degrees were in other science, physics, and technology fields.
Several astronauts with doctorate degrees have them in medicine. Currently there are eight astronauts with medical degrees (and one veterinarian). There are four with physics degrees. For engineering:
Aerospace Engineering: 3
Mechanical Engineering: 2
Chemical Engineering: 1
Polymer Science and Engineering: 1
Electrical Engineering: 1
The rest are in different biology fields, chemistry, and geology.
Past Astronauts: There were 49 past astronauts who earned a Bachelor degree, 146 with Master degrees, and 102 with Doctorates.
For Bachelor degrees, Aerospace Engineering degrees dominated this category as well.
Aerospace Engineering: 23
Mechanical Engineering: 5
degrees listed only as "Engineering": 3
Electrical Engineering: 2
Engineering Physics: 1
Engineering Science: 1
Systems Engineering: 1
Engineering Management: 1
The rest of the degrees here were in mathematics, physics, sciences, aviation, and business.
Of the 146 Master degrees, a very high number of them were in engineering, and nearly half of them were in Aerospace Engineering (including Aeronautical Engineering, Astronautical Engineering, etc).
Aerospace Engineering: 69
Mechanical Engineering: 13
Engineering Management: 6
Electrical Engineering: 5
Nuclear Engineering: 3
Engineering Science: 3
Listed only as "Engineering": 2
Flight Structures Engineering: 1
Ocean Engineering: 1
Metallurgical Engineering: 1
Materials Science Engineering: 1
Electronics Engineering: 1
Engineering Mechanics: 1
Ceramic Engineering: 1
There are also several degrees in this category in Management/Administration (15), Computer Science, Physics, Aviation, Mathematics, Education, and other sciences.
Past astronauts with Doctorates are varied, but the highest number of the 102 are in Medicine (23). As for engineers:
Aerospace Engineering: 10
Mechanical Engineering: 7
Electrical Engineering: 5
Chemical Engineering: 3
Material Science and Engineering: 2
Civil and Environmental Engineering: 1
Listed only as "Engineering": 1
Biomedical Engineering: 1
Hydraulic Engineering: 1
Other high numbers in this category include: Physics (14) and Astronomy/Astrophysics (10). The rest include Meteorology, Geology, Law, Computer Science, and other fields in physics and science.
From what I can see, they seem to favor aerospace engineering, but that shouldn't really come as too much of a surprise. What did surprise me is that about a quarter of all astronauts who earned a doctorate degree earned it in medicine. The number of degrees at that level in medicine is about equal to the degrees in all the disciplines of engineering combined. It looks like most of the doctorate degrees are in physics, mathematics, and sciences.
For engineers, it looks like most of them earn Master degrees. Nearly three quarters of all astronauts with Master degrees have them in Engineering. Aerospace, Mechanical, and Electrical Engineers have the highest numbers by far, especially Aerospace. It looks like if you want to be an astronaut, having a Master degree in one of those disciplines is most valuable.
This will be a subjective answer to a subjective question (I was not going to answer at all, but @called2voyage's link ([Good Subjective/Bad Subjective])1 (see @called2voyage's comment to the OP, above) emboldened me...). Please keep in mind that the experiences shared below were attained during a period of time lasting from the mid 90's to the early 00's.
Based on my personal experience in NASA's Astronaut Office, I'd say the best educational course to follow, if one wants to make oneself most eligible for selection to said Astronaut Corps, is to first bone up on NASA's current education requirements. Gotta meet those requirements!
However, said requirements encompass a vast array of educational degrees. How to choose?
Here's what I've seen with my own eyes and still believe to be true: Within the above boundaries, the choices are mostly irrelevant. What matters most is that one excel at one's chosen field. So, AFAIC, the choice becomes simple - choose a field that you are both passionate about and very good at. A superior candidate with a Master's degree in Engineering Mechanics (for example) will be chosen over a mediocre candidate with a Master's degree in Aerospace Engineering (for example).
Choosing a field you are both passionate and very good in will maximize your changes of excelling in said field, which then maximizes your chances of being selected to join NASA's Astronaut Corps.
I will be applying for the recently opened Astronaut Candidate position, and I have a Ph.D. in optical engineering -- everything from cameras, detectors, optical systems, radiometry. However, and more importantly, I have had the pleasure of speaking 1-on-1 with 2 astronauts who both alluded the following: While NASA does look favorably on an advanced degree, your initial field-specific education (like mine, in optics) had 0% influence on what they wound up doing during the mission. NASA, I think, trains you in what they think you should know. If you haven't learned it by then, they will teach you (granted your application gets accepted).
That said, a Ph.D. in an engineering field can take the place of years of flight experience that you would have built by going the route of a military pilot. I do agree w/ @Daniel Cleaver 's answer.
The obvious engineering discipline would be aerospace engineering. Though mechanical engineering and some of the applied sciences would also be good options to consider. It would probably also be a good idea to obtain an advanced degree in your field. Many astronauts have held PhD's. I say aerospace because it will give you a solid foundation in many of the topics astronauts must know - orbital mechanics, for example.
If you don't want to go down the military flight path, it wouldn't hurt to get some civilian flying experience to help your application. You should also consider becoming involved in activities such as mountaineering or SCUBA diving to show you can work in a hostile environment. Since current and future space missions are likely to be multinational, you should also learn a foreign language such as Russian. You should also aim to be very physically fit.
Of course, that was a very long list. Becoming an astronaut is no easy task and very few who set out to get there actually make it. Best of luck to you.