The Sources criticize the tribes of Reuben and Gad for two things: Not settling in the Land of Israel and placing their cattle above their children. [Midrash Tanhuma, Matot, Siman 7; Numbers Rabbah 22:9; Proverbs 20:21] They were punished by being the first of the Ten Tribes to be exiled.
1-They did not settle in the Land of Israel because the land east of the Jordan was better for their cattle. They got permission from Moses, in exchange for fighting with the other tribes in the frontline, which they did for seven years. Whether or not a Jew is commanded to live in the Land of Israel is still a matter of dispute. Naḥmanides says yes and Maimonides says no, according to the lists of 613 they left us. Both sages acted on their beliefs. When Maimonides was forced out of Muslim Spain, he lived only very briefly in Israel, then moved to Egypt, did all his work there and died there. When Naḥmanides was forced out of Catalonia, he went directly to Israel, and worked and died there.
2-They said: "We will build here enclosures for our flocks and towns for our children." [Numbers 32:16], and Moses gently rebuked them by reversing the order: "Build towns for your children and enclosures for your flocks". [Numbers 32:20,24] But there is no commandment to build dwellings for your children before you build enclosures for your cattle. And they never said they were going to start with the cattle pens, they only mentioned them first to emphasize that they were settling there because of their cattle.
So what commandments did Reuben and Gad break?
One could argue that the Torah says: "Be sure to keep the commandments… Do what is right and good in the sight of God." [Deut. 6:17-18] The Talmud says the repetition means that you must sometimes go beyond what is strictly commanded. Perhaps Reuben and Gad did not do that. But it's a very subjective matter.