I have a Dell P2723QE with similar issues with my M2 MacBook Air connected with USB C. Apparently Dell has said the P series is not fully compatible with the Mac. Or at least this is what I have been told. Probably good you returned it.
I bought two dell u4021qw and I have not experienced any flickering. However, considering the price of this model I would expect them to support a newer version of the HDMI standard. Connecting with USB-C and DP works fine and will give you full resolution of 5k something, but none of the HDMI inputs are able to give full resolution. So if you do not plan to use HDMI I can recommend this model, I normally work 10 hours a day six days a week and have not experienced any eye strain. The monitor is supposed to have some kind of built in anti blue light stuff which I know nothing about, but I spend a lot of time comfortably in front of the screens. I use the monitors with a older macbook m1 pro, and a newer higher end thinkpad. Like yourself I work as a developer, doing a lot of coding so a good monitor is important.