That knocking is the actual noise you hear, right? Doesn't sound anything like a ground loop or any sort of random noise, it sound rather funny (unless you have to stand it, of course).
From your description it doesn't sound to me like an issue with the line output (RCA), though. Since switching to a different input and then back to WiFi obviously cures the problem, the issue might rather be with the input side.
Switching the WiiM back to WiFi using the WiiM Home App doesn't necessarily mean it is connected through AirPlay again. It's just ready to receive input from any source fed through WiFi, like e.g. any streaming service.
By turning of the TV you are referring to the actual TV screen or the Apple TV? Just guessing, this noise could be the manifestation of some AirPlay handshake being not successful. But it's a strange noise, indeed.