How was part of the Austrian empire inside of the Holy Roman Empire while the rest of it wasn't? Similar things go for Prussia. How could entities which were part of the Holy Roman Empire expand and yet those new territories would not belong to the Holy Roman Empire?
The land within the Empire and without the Empire was a personal union not a unitary state. The Hapsburg Emperor was also King of Hungary but they were both separate entities with different laws and powers of monarch. So land added outside the traditional area of the HRE would result in two different titles held by the same individual. The Elector of Brandenburg and the Duke( and later King) of Prussia were one and the same person. So when Prussia expanded into Poland those areas would legally be part of Prussia not Brandenburg. However in 1701 the government of Prussia and Brandenburg were amalgamated into one and the whole point was rather quietly ignored.