Why would a golf course restrict carts from venturing off the designed cart paths and onto the grass? As noted, most often it has to do with rain. Those riding carts are heavy, especially loaded down with golf bags and golfers. Drive one onto saturated turf and you can do real damage to the grass.
Golf courses might designate the entire course as cart-path only, or might designate only certain holes as such. Perhaps some fairways handle rain better than others, for example, so the cart-path only designation might apply only to those fairways with poorer drainage.
How do you know when "cart path only" is in effect? If it is, you should be told at check-in if you request a golf cart. Another way golf courses alert golfers is through the use of little signs stuck in the ground near the first tee (or near the teeing grounds of individual holes). These signs usually read "cart path only today" or "cart path only on this hole."
If a course has any holes that are always "cart path only" - it's not uncommon for par-3 holes to always be designated as cart path only - then in addition to any on-course signage such a rule may also be noted on the scorecard.
The bottom line is that the specific reasons "cart path only" rules are in effect at any give time aren't important; just know that the superintendent is trying to protect the grass.
See also: Golf cart rules and etiquette
"Cart path only on No. 8 and No. 12 today."