Network Rail will have to pay £2m after the rail watchdog found it in breach of its licence agreement.