As I had read in books on Indian History (which certainly do not discuss ideas in detail), the caste system as had been originally devised was not rigid; in other words, a person 'born into' a caste could change his work and thereby, shift his caste. I am curious to know if the scriptures give us an idea about the transition of the nature of the caste system. On a side note, I'd also like to know if untouchability prevailed during the ancient times.
Is there any writing in the scriptures that tell us how the caste system went from fluid to rigid?
No, the caste system never went from fluid to rigid. In fact, only in modern times is it going from rigid to fluid.
I will cite from ancient scriptures like the dharmashastras of Manu, Apastamba, and Itihasas like the Mahabharata to show that the consensus in ancient times among scholars was that the caste system was birth based and that caste is fixed from birth.
Manusmriti 10.5: Among all castes, those only who are born of consorts wedded in the natural order, as virgins of equal status, are to be regarded as the same (as their father).
Āpastamba (2.13.1).—‘Sons begotten by a man who approaches in the proper season a woman of equal caste, who has not belonged to another man, and who has been married legally, have a right to follow the occupations of their castes.’
Viṣṇu (16.1).—‘On women equal in caste to their husbands, sons are begotten who are equal in caste to their fathers.’
Yājñavalkya (1.90).—‘From women of the same caste as their husbands are born sons of the same caste.’
Baudhāyana (1.17.2).—‘Sons of equal caste spring from women of equal caste.’
Caste promotion only happens in subsequent lives, if they have correctly performed their duties:
Āpastamba (2, 11.10-11).—‘In successive births, men of the lower castes are born in the next higher one, if they have fulfilled their duties. In successive births, men of the higher castes are born in the next lower one, if they have neglected their duties.’
Vidura in the Mahabharata war was a Shudra who was very well respected and revered by Brahmanas due to his Brahminical qualities. Many Brahmanas came to him for knowledge. However, even though he could teach some knowledge, he could not instruct them into upasanas and mantras. He says:
As I was born a Shudra, I cannot teach any further. - Mahabharata, Udyoga Parva, 41-5
Vedanta Desikan, a medieval Sri Vaishnava scholar, says this about caste elevation and exceptional cases like Vishvamitra, etc:
Those who abide by the shastras should not believe in the elevation from lower castes stated in the deceptive shastras of heretics. The case of such as Vishvamitra, who became a Brahmin after being a Kshatriya, was due to certain special causes as the charu eaten by his mother without knowing that it was intended for producing a Brahmin child - it should not be considered that it is applicable to others as well, for it is against the texts in the shastras. The incidents and conduct of the Alvars who were possessed of powers even superior to those of Vidura and others should not be taken as precedents for our conduct. If we examine even their conduct carefully, we shall find that they did not transgress the rules of their respective castes. - Rahasyatraya Sara page 303
So, ancient Hindus followed a rigid, birth based caste system.
It is only in modern times that many Hindus believe that the caste system is based on self-identification. Vivekananda was the main person to promote this trend, and reformist Hindus have now adopted this belief. Orthodox followers of Vedanta do not believe that caste is based on anything other than birth.
For verses from scriptures like the Mahabharata that appear to talk about caste elevation in the same life and guna-based caste system, take a look at the correct interpretation in this answer.
Also take a look at my answer here that shows that the Vedas declare that caste is based on birth.