Well, in a swamp all he would have is tree bark and stuff that nature provides. So he can't build a light sabre out of that probably. I dunno if he packed spare parts for a new light sabre in his little escape ship.
As for why Lukes light sabre still worked in the swamp.... It probably hadn't rusted out yet. Stay there long enough and maybe it would have.