Let's not blame security too bad. This guy was caught in the act. What more could you want security to do?
You can't fence off the entire yard. You'd still need a way for the trains to enter and exit. Gates are not practical for a busy yard like Hillside.
As was posted above, photo bans were used in the past. During WWII, there was a ban on photography as well. Like it or not, railroads are considered part of our national security, and have always been considered targets. In WWII, Nazi saboteurs boarded an LIRR train at Amagansett to commit acts of war on American Soil. One of their prime targets was Horseshoe Curve and other vital rail links.
Railroaders are now required to report all suspicious activity that is observed. While I might know the difference between a railfan and a serious threat, many others will call it in, and have to waste law enforcement's time to check it out, instead of fighting real crime. I'm sure that officer isn't going to want to hear about the constitution, civil rights, etc. (They've heard it all before.)
Jay