I found out by testing that the full release of the game doesn't have the glitch it's only the beta/preview.
This seems kinda like a glitch that I posted about here MCPE-162293 and if it is based on the same premise then the steps would be to place two chests down and have them facing the same way with the same item inside then do "/testforblocks (first chest location) (first chest location) (second chest location)" but that's if the glitch still happens because I'm no longer in the beta/preview.
Yes this does seem similar to MCPE-161257 and I think the if blocks statement in the /execute command is the same as /testforblocks but MCPE-161257 is close now due to not having the steps to reproduce the bug.
The issue happens on android too and I think it's because the /execute command isn't getting the facing direction of the entity like it should because ^ is a coordinate that is based on the facing direction of the entity running the command (which should be the executed entity if run as /execute as) but it doesn't seem to change it from the command blocks "facing" angle. Here is a link for an example https://m.youtube.com/watch?v=QE3efE5DI4k
What I did to cause this issue was took the entire com.mojang.minecraftpe file path from Android/data on a device running Android 11 and placed it in the Android/data path on a Samsung S23+ running Android 11 which caused the issue shown in the video.