I thought it might be good to offer an example of a different model of preparation for teaching. I did not teach until I was in my fifties, as my second profession, but the way I proceeded was one that younger people can do as well.
I was an attorney for about twenty-five years when I realized I was burnt out and would like to try my hand at a new and different profession, teaching. Because I was something of an expert in one area of law, I was able to teach a law course at a local college in the evenings, and this was a good tryout for me, to see if I would enjoy teaching and whether or not I might be any good at it. Like readerofbooks, I needed to have some sense of what I was getting into.
I set my sights on teaching high school English, and luckily for me, I had an undergraduate degree in English. Having a degree in the content area in which I wanted to teach meant I had sufficient credits in that area to be admitted to a master's degree program in secondary education. So there is not necessarily a need to take undergraduate credits in education or have a degree in education in order to become a teacher. If you wish to teach math and have a degree in it, you can move right on to a master's in education, for example.
No matter which route you take educationally, you do, as readerofbooks says, want to immerse yourself as much as possible in the content area you wish to teach in and develop the skills you need to teach in that area. Fortunately for me, I have been an avid reader and writer all my life, just for my own pleasure, and that gave me a lifetime of practice in my content area. Also fortunate was that the skills necessary to be a good attorney were skills that translated well to teaching, research skills, logical thinking, the ability to read people well, and adept communication.
Once I had completed my coursework, I had to do a practice teaching semester, with a cooperating teacher and a supervising professor, who worked closely with me while I taught a few sections of English to high school students. I took the test to be certified to teach English and was thus credentialed to teach English in grades seven through twelve. In my state, and I believe in other states, once you are able to teach in one content area, you can take the test to be certified in some others, too, even without the undergraduate degree or coursework in that content area. So I took the test to teach social studies, too.
Whether you get an undergraduate degree in education or an undergraduate degree in a content area and then a master's degree will be your choice. But you will want to see what is more desirable in the area where you wish to teach. Some school districts favor a content area undergraduate degree and a master's in education, while for others, it does not seem to matter. And no matter what, keep learning about your content area, since this learning will be invaluable to you as a teacher.