How do raccoons get on your roof is not as important a question as why do raccoons want to get on your roof. Raccoons are aggressive territorial creatures that find a home and then refuse to give it up, so if they get into your attic the best way to get them out is to trick them with a one way door.
They get on your roof because they are very capable climbers. They can scale almost any material and can climb and jump trees to get to your roof or even just climb up the drain pipe. They can get onto your roof in dozens of way and their are few ways to stop them from climbing your building but you can stop them from getting up their easily. You can try making your drain pipe harder to climb with pigeon spikes that may deter the raccoon from trying to climb it.
You can also try putting aluminium collars around your trees bases to stop them from climbing and trimming back the branches to stop them from hopping one tree to another. This is not the only reason they are there though. They are also attracted to the garbage on the property which they are happy to tip over, rip open and spread across your property like a Jackson Pollock painting.
So seal all your garbage in a tight container and store it in your garage to keep it safe, you should also do the safe with your bbq if you tend to have dinner outside frequently. Food gets dropped all over the place and will attract raccoons. You should also not feed pets outside as they also spread food raccoons like to eat. If you follow these recommendations then you should have no raccoon issues on your property.