The owner of the property is responsible for all taxes and fees (including HOA). When a bank takes back a property, it assumes all the the costs of ownership.
The problem for HOA's is that the banks typically do not pay the HOA fees until the property is resold, and then the HOA gets all the back fee's out of the escrow. So if 1/4 of your associations units are REO and just sitting there for a year, your HOA revenue is down 25% and the remainder of the owners are screwed. HOA's can take the bank to small claims court (or muni court) but typically, the legal fee's outweigh the effort and you wait until the property sells to bring the account up to date.
The other problem is the HOA's fee prior to the foreclosure. If an owner isn't making his/her mortgage, their not making their HOA dues either. The bank is not laiable for any fee's prior to the foreclosure and if the owner is BK, the HOA is SOL.