How does android wifi hotspot work when other wifi is available?
When your phone is in hotspot mode, it will only use your mobile data.  You'll need to remember to switch the hotspot off when you have wifi available.

You might be able to script the shutting down of the hotspot with Tasker or Locale, but I'm not sure if the "WiFi near" function would work when in hotspot mode (a good topic for its own question).

Your Nexus 7 will tend to connect to the strongest signal available, and then stay connected to that network until it loses the connection.    When you turn off the hotspot on your Nexus 4, the tablet should auto-connect to an available Wifi network.