This is answered by the in-game civilopedia for Embarking Units
And in text (for search engines):
At the start of the game, your land units cannot enter any water tiles. However, once you've learned Sailing technology, Builders will be able to move into coastal water tiles. After Celestial Navigation, Traders will be able to embark. And after Shipbuilding, all units will be able to embark. To embark a unit, move the unit to a coastal tile and then click on the "Embark" Action. Once embarked, the unit must move into water.
Note that in civilization VI, you do not have to visit friendly territory anymore to gain this ability.