States do fund residency. This site says that state matching of federal Medicaid funds is ~12% of the total funding:
https://mostpolicyinitiative.org/science-note/state-supporte....
Interesting related thread: https://www.reddit.com/r/Residency/comments/a01cfr/funding_y...