I feel like I've seen this for multiple reasons with various species. Here are the ones coming to mind:
1. It's a wild fish that isn't used to being in a clear box.
2. It's a territorial fish that sees its reflection (less common, may depend on tank shape).
3. It's a tame fish and it wants you to feed it (e.g. many cichlids).
It sounds like #1 is the most-likely in your situation. If that's the case I'd expect the blackout idea to work, as the fish can get used to where the walls are quicker if they don't look clear. I'd also expect the behavior to go away on its own eventually, but sooner is always better. Fish can get sores on their snouts if they rub them too much.