A Royal Navy submariner who groped a colleague at Faslane while on bail for another sex attack has been jailed for two years.