You are right in that people already have biases and prejudices and even though it perpetuates a wrong paradigm -- if you are consultant and try to make as much money as you can these perceptions (even though detrimental to the industry) matter.
It should really be coming from the top and be part of the culture that hours spend huddled over a monitor != better or high quality/faster/less bugs products. But we are not there yet. So should one leave for another place, and find that culture (work for a startup?), or work with it, as in just pretend you work harder to get noticed better...
So I am not defending the idea behind it, but your rationale for working with it.
Think about this scenario. It is 8:30pm, manager/owner walks by and he sees group of developers huddled over a monitor screen. What is happening? Is this a good thing or not? Are they working extra hard and deserve +$5k bonus at the end of the year, or they picked a bad technology, made bad mistakes in the implementation, allowed untested code in production and now have to put out fires. I think the opinion on the above will be pretty divided, but, unfortunately, it will mostly be seen a good thing. This spreads and becomes part of the culture, and those that are productive and finish their work faster, whose code doesn't break in production leave at 5, and are seen as lazy by incompetent managers. That is very dangerous.
The worst I have seen is people what seems like to me, intentionally allow bugs in production, things crash and burn. Then, they get to save the day with lots fanfare and visibility. That becomes a very dysfunctional environment from which one should try to escape as soon as possible.
My comment was really aimed more at the reality of the situation: when operating in a political environment (as every office is, like it or not), it's better to err on the side of being visible. Like I said; some people are perfectly content with maintaining the job they are currently in, and there's nothing wrong with that. But if you have ambition to move up into management, simply writing good code isn't enough. You've gotta play the political game at some point or another, and the political game often happens late in the day after all the senior management are done with their meetings.
This is doubly true for a consultant. An unfortunate reality of consulting is that when you're on short contracts -- as most consultants are -- you have to sell the next project while you're working on the current one. Being visible and physically present leads to the conversations that end in your client asking you to help them out with a problem. These are not "hard sell" tactics (I always hated those because it makes you come off as scummy and sales-ish); it's just making sure that you're in the right place at the right time and you're having the right conversations with the right people.
This doesn't have to mean working yourself to death -- I usually leave around 5:30 and almost never stay in the office after 6:00, nor do I typically work more than 45 or 50 hours a week. Do I wish I could go home at 4:00 some days and not be negatively perceived? Yeah, I do. But that's not reality, at least not anywhere I've ever worked. If the social norm is 9:00am-5:00pm, you should probably be there during those hours because an 8 hour work day really isn't asking much. If the social norm is 8:00am-7:00pm, well, you should probably find a better job...
Compared to what? A guy that stays in the office 80 hours a week and barely hits the productivity level of 40 hour per week guy?
There is nothing 'obvious' about that, I bet you would judge your engineers productivity by LOC too.
There's nothing wrong with that; it's perfectly fine to value running with your dog or watching Netflix over working an extra hour; but the choices you make have unintended consequences. Like it or not, working involves politics, and a big part of politics is perception.
I've worked as a consultant as well; and as a consultant you can never be the first person out the door because people who don't know your situation will still form opinions about you. Considering most consultants cost 2x-4x what a salaried employee does (at least nominally), you have to appear to be "better" than the average employee. Sometimes that means you stick around the client site and do work for other clients just to look busy. But it almost always means you don't leave early. The same goes for people who have ambitions of moving up in an organization.