Um, Apple didn't include Target Display Mode on 4k 21" iMac or on 5k 27" iMac.
So there's your problem...
Or, if you knew that already, one common observation is that Apple loves to gradually solve issues and dole out those solutions. They seemingly haven't solved some issue with Target Display to their satisfaction. What else can be said?