In ancient times, switching between castes was possible.
There are many Kshatriyas who became Brahmin. For example, the elder brother of King Shantanu of Mahabharata became a brahmin. In fact, he became a Rishi. His name was Devapi. Maudgalya Brahmins have Kshatriya ancestor, actually. Also, we all know the famous example of Vishwamitra.
The opposite was also not uncommon. The great King Bharata adopted a Brahmin and made him his successor. Bharata had sons, but he did not think them fit to rule the country. So he did that.
But in Dharmasutras, we do not find any provision for changing caste.