Why didn't some of the previous Buddhas preach the code of discipline? It is said that as some of the previous Buddhas did not set the code of discipline, the Dhamma did not last.
The Vinaya pitaka is preached only if the life span is less than 50,000 years. When the life span is higher, the human world is said to be similar to heavens. The Buddhas usually introduce Vinaya rules when someone commits a misdemeanor. But the people are very virtuous during these times. So the need to introduce new rules does not arise.

Ironically, the Dhamma lasts longer when there's no Vinaya pitaka, due to the much longer life span.

Additional info: https://www.youtube.com/watch?v=x_CWFS-rca8