A theory for the emergence of channelized drainage