For safety and security, including operational reasons, the Captain and via the Captain the rest of the crew may, of course, limit access.
But, this is odd and, if a reason was not provided to you when you asked the FA why access was limited, I would send a note to UA noting that you were seated in F (I presume that you were although you do not say that you were), that this was a long flight and that access was prohibited for the entire flight without any specific announcement.
You won't receive a satisfactory answer, but it may cause an inquiry to be sent through.
I do suspect that there was some decent reason because it is the sort of thing which does generate complaints and the crew know it.