Though announcement of US national security adviser's departure came abruptly, the divide between him and Trump had been widening for months