Hmmm. It scraps ships? Interesting. I normally play on larger maps where I don't get to observe this early behavior.
It should definitely consider maintenance cost afterwards. Could it have been making a bad estimate of its resource production (e.g. battles cause its happiness to drop enough to lower production to the point where it unexpectedly couldn't afford it)? Maybe it didn't have enough reserve minerals, et al, to refit -- but that seems unlikely. My spies can usually leech off a decent amount of resources from an AI, at least until said leeching starts to hurt them.
This -- bookkeeping, not prediction -- is one of the things that it should be able to do better than a (lazy) human; I, for one, don't sit down with a spreadsheet or notebook and track expenditures, et cetera. It means I play very suboptimally, no doubt, but I prefer to be more freewheeling.

But a machine can handle the tedium without complaining.
Maybe scrapping doesn't cause the happiness hit that a lost battle would? Hrmmmm.
------------------
-- The thing that goes bump in the night