As a computer professional, one of the most important, and sometimes most difficult things to remember is that your job is not really to write code, create web pages, keep systems running, or otherwise work with computers but to meet the needs of the company or person you work for. It doesn't matter if you write the most interesting, technically perfect code in the world if it doesn't do what the company needs. It doesn't matter if your systems have an uptime in years if people can't access them to do their job. Perfect security is useless if people can't send necessary business data to a business partner. Whatever you are doing needs to be supporting the needs of the company.
Sometimes this means doing things that you think fall far short of best practices or otherwise is inappropriate. If this is clearly in the best business interests of the company, you need to just go with the flow and do what you have been asked. However, if you believe it's not, then determining the best course can be much harder. If what you are being asked to do is illegal or unethical, then hard as it may be, you need to speak up first up the chain of command, and if necessary even to the outside world. More often, you'll be asked to do something that you feel is inefficient or bad for business. In this case, you should first decide whether it is really important or just trivial. If it is important, make sure that your view is the correct one. I recommend asking directly, not from the viewpoint of someone trying to point out a problem, but as someone who is honestly trying to understand the business goals. People are usually happy to talk about their job and what they need to get it done, particularly if you develop a reputation for following through and helping them do that. Once you understand the goals, if you still feel like there is a disconnect, then you can start asking why your ideas aren't appropriate. Often though, once you have a better understanding, your course becomes much more clear cut. You may feel comfortable going and doing what you were initially asked to do. Or you may have a new idea that better meets both your sense of what is technically right and the business needs. If you still feel like what you are being asked to do is the wrong way to do things then you are likely in a position to present it as a potentially unforeseen risk - you can say something like "I'm concerned that if we do it this way, we will be at the risk of X", where X could be something like using unsupported technology or falling behind the competition or whatever your concern is. Be prepared to explain why you feel that way, and ask if that risk is being handled in some way. Often this will allow you to come to a solution, or failing that an understanding, that you are comfortable living with. In the rare case where the risk isn't being handled or isn't being handled in a way that you are comfortable with, then you need to think seriously about whether you are at the right company for you. If you aren't comfortable with how your employer handles risks, do you believe your company will be in business for the long term? If so, why are you still uncomfortable?