Concerted hydride and alkyl shifts
The SN2 reaction involves an attacking group and a leaving group moving in concert. A pentacoordinate transition state is involved.  Typically, there is no rearrangement in an SN2 reaction.  Similarly for an E2, as a base removes a proton. a leaving group is ejected in concert to create an olefin, no rearrangement products are observed.

It is the SN1 and E1 reactions that proceed stepwise through distinct carbocation intermediates.  As the carbocation is being formed in these reactions, a hydride or alkyl group can migrate to produce a more stable cation.

The leaving group can be things other than a hydroxyl group, for example chloro, bromo, or iodo groups make good leaving groups.  Back in the early days of physical-organic chemistry many alcohols were used in reactions simply because they were readily available as natural products.  Alcohols could also be readily converted into acetates,  tosylates, brosylates, or other sulfonate esters, which were even better leaving groups and allowed for reactions to proceed under even milder conditions.