I've been thinking a lot about the Galaxy class starship and really trying to understand what the showrunners were trying to do with it as I prepare for my next scale model project of the Enterprise-D and I've come up with an answers that, I think, accounts for this.
Just what is the Enterprise-D?
Well, looking just at the design of the ship itself, we find a ship that has a standard Starfleet crew, but has hundreds of civilians, including children. The ship is plush, soft, comfortable. It has potted plants,

artwork, a theater, concert hall, comfortable places to sit in the corridors,

at least one lounge (Ten Forward),

an arboretum, multiple holodecks, lavish crew quarters,

and a bridge that seems to look more at home on a cruise ship than a military vessel.

If you had never seen a single episode of Star Trek: The Next Generation and knew NOTHING about this ship other than it's NOT a cruise ship, what would you think of it? What would you think the purpose of this ship was?
If your answer is deep range exploration, where the crew would expect to be underway for years and years at a time without shore leave, spacedock or the chance to go home, then you're right. All the comforts and amenities suddenly make perfect sense, as you'd want a ship where people could live for years at a time without ever setting foot on a planet surface and still feel at home and comfortable. You'd have bright lights, large rooms, comfort and lots of amenities.
That being the case, it's easy to see where the Enterprise-D's mission really is more analogous to this ship's:

than that of any military vessel. If you're not a Babylon 5 fan, this ship is the Cortez, a deep range exploration vessel whose job it is to explore beyond known space, chart stars, make first contact and return home with knowledge and new data.
Sound familiar at all?
And yet we Trekkies often make the argument that the Enterprise-D is more an example of a military vessel, perhaps a battleship or at least a heavy cruiser. Why is that? There's nothing about the appearance of this ship:

that says "military."
Come on, guys, let's be honest. It doesn't and you know it.
So why do we think of it as military?
Because the show writers wrote so many militaristic episodes and roles for this ship. That's why.
Let's be honest. Having a Federation starship in a pitched battle with a Romulan Warbird is a way more exciting prospect than that same ship plotting *gasp* yet another gaseous anomaly. Exploration stories can be interesting but they can also easily become old, boring and tired. So every once in a while the Enterprise had to charge phasers and go guns blazing... well okay that's fine... but the writers took this too far.
More than once the Enterprise is described as the command ship for the sector. This is why Captain Picard was captured by the Cardassians and interrogated. This is why Picard commanded the task force that blockaded Romulan space. The Enterprise was conceived as an exploration ship, designed as an exploration ship, described as an exploration ship, and then was constantly put in military roles to keep the show exciting.
And it is definitely a contradiction. Why would a deep range exploration ship be in federation space so much that it could serve in the role of sector command ship? Why would it be staying in a local sector? Enterprise was constantly ferrying diplomats, medical supplies, responding to distress signals... It almost never seemed to be out doing the thing it was designed for.
It didn't help that the Enterprise seemed to return to Earth more often then every other featured Federation ship combined.
This hurt our ability to latch on to what this ship was supposed to be. We were constantly told it was a ship of exploration and yet it was a diplomatic transport. We were told it was a ship of peace and yet it was constantly firing weapons. In Deep Space Nine we often saw massive space battles with several Galaxy class starships involved. Why weren't these exploration ships out exploring the edges of Federation space? (Well, the answer is because it was cheaper to re-use the Enterprise-D models. That's why we also saw plenty of Miranda and Excelsior class ships.)
I'm not saying these things to be critical per se. The show had to be exciting or nobody would watch it. I think the problem was that the initial idea of the Enterprise-D was just unrealistic for the television environment. There's a reason Babylon 5 didn't feature the Cortez or any ship like it.
What's weird is that, internally, the various showrunners did keep the Enterprise's true nature in mind. For instance, the Voyager, featured in its own show, was much smaller than the Enterprise-D with less than half the crew and yet was faster, and more maneuverable than the Enterprise, and outgunned her with more powerful weapon systems. That's because Voyager is more like a warship. In a stand up one-on-one fight Janeway's Voyager would blast Picard's Enterprise to bits. Still comfortable and lavish on the inside, that doesn't seem to ever go away, but she did not have all of the amenities and interior space Enterprise-D had.
So what's the point?
The point is that this is why the Enterprise-D seems to contradict itself so much. It was intended to be a ship purely for exploration in deep space, but the writers didn't use it in that way very often. So we're left with the history of a military vessel but the design and appearance of a deep range explorer.