The second sentence introduces the hat (as a target of comparison) as a topic.
But just because the first sentence doesn't, it doesn't mean that the sentence isn't about the hat.
The grammatical topic is more than just what a sentence is about.
The topic is a lasting effect which a sentence has on sentences or conversation which follows. For example, when we introduce a topic, then the next sentence can implicitly be about the same thing without mentioning it.
(Topic is now その帽子に: the hat as a basis of comparison)
(From the lingering topic, the jeans go with the hat, and not the scarf or something else in the speaker's and listener's environment.)
Moreover, just because there is no topic marking particle doesn't mean that the sentence does not introduce a topic. It just does so perhaps less firmly. In Japanese, elision of particles is possible, and they can be understood as being "still there" but replaced by a "null particle". For instance see this paper which discusses some possible rules and circumstances under which wa can be dropped.