Which part of the hamstring have you pulled? do you know exactly what motion caused the tearing? the hamstrings made up of three different muscle groups if you can isolate what muscle(s) is/are torn then you can isolate what caused it and how to treat it.
There are many reasons for pulled muscles and cycling has been used as a sort of 'rehab' for severe hamstring pulls. It definitely uses the muscle but not to the degree other sports like running etc
From your post i would say if your having severe difficulties waking or unable to walk without support then its possibly a grade 2. If its a grade 3 (which is quite rare) then you need to see a pro. In the mean time i would use cold therapy, compression can sometimes help decrease intra-muscular bleeding but its also important that as soon as you can do a stretching & strengthening routine, you do so. For someone as active as you, you really need to promote correct orientation and re-alignment so to speak.
If you have a physio friend or family member or can get access to sports massages that specialise in muscle repair then that'd be great, its a very good way of reducing scarring which can later cause more pulls.
As far as why you pulling that's a hard questions. Muscle fatigue causes poor form and overloading hence the pulls, age naturally is a cause of more pulls if you don't use a proper stretching routine, muscle imbalances (biggie for cyclist) can cause pulls, flexibility is another big cause, previous scarring increases the risk massively and things like dehydration i believe is known to increase the risk. So all in all you gotta keep on top of these things. Definitely start stretching!!
All in all, stretch, look for muscle imbalances,stretch, keep hydrated, stretch, try not to tire yourself out, stretch, improve your flexibility if your worried (its always a good thing to do anyway) and stretch... Seriously though, stretching and a good warm up will help you no end.