Are rubs on trees used by a buck to mark his territory or do they just rub trees at random to get the velvet off?
Both. During the rut a deer with a polished rack will still make rubs to advertise his presence.
and build his neck muscles
Fireball has it right. Those slits below the eyes -- suborbital glands -- secrete scent-laden "sebacious" fluids that identify specific bucks and bulls to others of their kinds. Whether this is an actual territorial marking is in doubt; more likely just an "I've been here ... and here ... and here!"
and does will be more receptive to a handsome big fella with a nice looking rack. I personally watched a doe hanging around a fresh rub until a buck showed up the other night. Nature has it figured out.
Biologists say bucks do this because there are no bars open that serve drinks to deer. :bigsmyl: