Hi there, took me some time to find the reason for a similar error: My unicorn hat from time to time showed a single or a few randomly colored LEDs. Eventually (when I started some of the unicorn hat examples) all the LEDs were showing random colors and would change in some unforeseen order.
My raspberry controls a robot. So I have some other hats on it, too (servo controller, motor controller). I assumed that they did not work together properly. But after a while I found the real reason: Whenever I develop the robot software, I boot it with a HDMI screen attached. But when the robot should drive around etc, I boot it without HDMI display. The error occured only when the raspi was booted without HDMI display. After a few searches in the WWW I found the reason: The sound driver (snd-bcm2835) usually uses HDMI audio output. But when HDMI is not connected, it falls back to GPIO Pin12 (BCM 18) audio, so this is when the unicorn hat did not work.
Solution was to remove (or comment out) the driver “snd-bcm2835” in /etc/modules.