Summary:
The attacking unit initiates the melee by attempting to move into the enemy's hex. The attacker cannot engage in melee unless it can enter the defender's hex. (In other words, a Spearman cannot engage in melee combat against a trireme since it can't enter that space except when embarked.)
To order an active unit to attack, right-click on the target. The active unit will initiate the combat.