Shear flows in the scrape-off layer (SOL) and the edge pedestal region of tokamaks are shown to arise naturally out of transport processes in a magnetohydrodynamic model. In quasi-steady-state conditions, collisional resistivity coupled with a simple bootstrap current model necessarily leads to poloidal and toroidal flows, mainly localized to the edge and SOL. The role of these flows in the grad-B drift direction dependence of the power threshold for the L (low) to H (high) transition, and their effect on core rotation, are discussed. Theoretical predictions based on symmetries of the underlying equations, coupled with computational results, are found to be in agreement with observations in Alcator C-Mod [Phys. Plasmas 12, 056111 (2005)]. The effects of these self-consistent flows on linear peeling/ballooning modes and their nonlinear consequences are also examined.