To be fair, TV shows do this when they have no idea how many seasons they will get, and the stories naturally unfold, just as they would in real life. Real life is complicated, with many twisting corners, and there are no happy-ever-afters. What is absolutely wrong here is not the overall arc, which must surely have had some kind of planning involved, if only a few scribbled notes, but the retconning, and as you say...It boggles my mind that they didn't pre plan the entire trilogy before hand. That is the explanation for the majority of the shortcomings though. Failure to plan = planning to fail, as they say.
That is a recipe for chaos.directors knocking down and pulling apart each others creations.