The best way to prevent fin rot is by keeping very clean water with stable parameters, and making sure your fish is not subjected to stress that can lower its immune system.
Doing more frequent, small water changes and keeping healthy plants (to partially slow buildup of nitrogen compounds, and to help your fish feel more secure and therefore less stressed) with your betta will both help.
The tank should have a filter unless you are keeping tons of plants or are changing water daily (you still need to do frequent water quality tests with those methods though, and I wouldn't recommend them for beginners). It's also important that the tank is cycled, but if you already added the fish before cycling you should keep testing frequently and be prepared to do more water changes until the cycle finishes (can take a few weeks to a few months, depending on the tank size, filter, and bioload).
If you still get fin rot after all that, there are medications sold at large retailers available to treat it, though you might want to set up a separate small tank with just a sponge filter to treat the fish so that it's easier to dose and do the water changes between rounds of medication.
With proper care, bettas can easily live 5 years or more, and there is at least one account of one that lived around 20 years (though that was really exceptional).
I will add that back when I kept bettas in smaller tanks (I didn't know better, and probably many of the folks here fell prey to the lies of the tiny betta bowls before we learned better), they also were prone to fin rot and short lives. I now keep mine in 20-gallon or larger tanks with other fish, or in tanks at least 5-gallons if they are alone. Bigger tanks are much more stable, and I haven't had fin rot problems since I quit using the smaller "betta tanks".