As I understand it, recruits (those not slated for a seat at Navy schools training personnel in critical skills) are picked for the ceremonial guard based on boot camp behavior, military bearing, physical fitness, etc., with also an eye to the height of the person (generally low 6-footers, with some exceptions). Most of the other services select similarly (so that they all can blend in together during interservice efforts such as moving Ford's coffin up the Capitol steps).
There are also avenues for other junior personnel to apply for the program, but the needs of the Navy come first.