Part of this is just the nature of how modern day map makers treat early modern states: they'll lump all the territories ruled by a single monarch and present it as if it were a single unified entity. In reality, many of these states were what we call "composite monarchies", by which we mean they were not a single state as we might think of now, wherein all constituent parts of the state share a set of common institutions for governance. Rather, they constituted a multitude of different territories, all of which would have their own set of institutions for governance. Just to use an example, throughout the 16th and 17th centuries, we'll talk of "Spain" as if it were a singular entity, when in reality it consisted of the Crown of Castile, the Crown of Aragon, among others, each of which had its own internal customs and institutions for their rule, unified under the rule of a single monarch.
The Austrian Habsburg monarchy was a similar story. Looking at a map of the Austrian Habsburg lands, you can see the internal boundaries that were of substantial importance. What we think of as "Austria" can be broken into a variety of territories, loosely consisting of the Archduchy of Austria itself, the Lands of the Hungarian Crown, the Lands of the Bohemian Crown, along with others depending on the precise year we're talking about. Each of these territories was, in many ways, its own unified in the person of Habsburg monarch who was simultaneously Holy Roman Emperor, Archduke of Austria, King of Hungary, and King of Bohemia (again, among a variety of other titles depending on the year). Each of these territories within "Austria" and especially the separate kingdoms of Bohemia and Hungary were their own entities, complete with their own laws, customs, and institutions separate from the others.
To get to the core of your question, the answer is relatively simple: while the various parts of the Archduchy of Austria and Kingdom of Bohemia were part of the Holy Roman Empire, the Kingdom of Hungary was not. Thus, on a map that tries to show "Austria" as a single entity covering all of the various parts of the Habsburg composite monarchy, it will seem as though the boundary of the Empire cuts clean through "Austria", while--in actuality--the depiction of "Austria" as a single entity is the problem, and not representative of the nature of the monarchy as a whole.
Hope this helps to answer your question, and please feel free to ask any follow ups.