I'm considering entering into a terminal masters in mathematics program. I was wondering if after completing the masters, if most US PhD programs will accept the masters graduate classes I took as valid credits or make me re-take the courses at my new PhD institution.
To amplify the points in @ElizabethHenning's answer: in the U.S., in my experience in mathematics, in Ph.D. programs it's not so much "course credits" that are required, but some sort of "proof of reasonable competence", by local standards. That often certainly includes options to take an exam to prove competence (which would be helped by having your prior coursework), or sometimes by completing a (local) course with reasonable grades.
Here's the key point: why not give "competence credit" for courses taken elsewhere?
For one, if you want to claim that those external courses were sufficient for you to be competent, then you shouldn't object to demonstrating it in a half-day exam.
Second, at best it is very difficult to compare courses at different universities, all the more so to compare coursework done abroad to U.S. coursework... so, given the difficulty of comparison, we're back to just demonstrating competence on a half-day exam.
The "credit hours" themselves are usually not an issue in Ph.D. programs in the U.S., although a typical expectation is that people do register for some courses... since without sufficient registration advanced courses are often shut down by bureaucratic constraints. Advanced courses often do not have burdensome homework or exams, and are not meaningfully graded, so there's hardly anything to object to.
That is, in part, the question is a little misguided... and, no, coursework does not usually transfer in the sense of "fulfillment of requirements"... but you often can take a competence exam to fulfill requirements.