No, you are absolutely not required by law to work with a realtor on a foreclosure home. If your goal is NOT to work with a realtor, then you can probably accomplish that. Basically, there are the 3 ways to buy a foreclosure:
Pre-foreclosure. You can try to identify homes where the owner is behind on their payments and try to go directly to the owner and tell them you want to buy their house below market, and don't want to use a realtor. Good luck with that. Most people in that situation are embarassed, and under stress, or even working on a loan modification. If you like people slamming the door on you, it might be a perfect match for you.
Foreclosure Auction. You can buy a property at the court house steps. No realtor. Of course, you need ALL CASH, and it is best if you are experienced in construction and matters of title, as you are buying it "as is", usually with no opportunity to inspect the property, and you are assuming all title risk. Of course, you are competing with professionals who do it day in and day out. But you won't have to interact with any realtor!
Bank Owned Properties. If the bank take the property back, you can try to buy it directly from the bank. And I guess that might work, as banks are understaffed and overwhelmed keeping up with the volume. But I'm sure they are thinking "Hey, I have 238 messages from my asset manager and our disposition brokers regarding actual deals, but I will drop everything and take this call from someone I don't know who wants to buy our asset below its market value".
Banks are not charities. They are not in business to give you a good deal. They are in business to dispose of their asset as close to fair market value as possible. Therefore, they generally work with (here's that word again) Realtors. Once a property goes on the market, it will be listed with a realtor, so no way to avoid working with a realtor at that point.
Again, if your goal is not to work with a Realtor, then you can probably find a way to do it. I guess the operative question is why? There are many highly professional realtors on this site, and they bring real value to the table. And they will save you countless hours of time.
Good luck with your search