How does infection work?
The main thing to understand is that exposure to a virus doesn't necessarily mean you will experience a sympomatic infection. You can be exposed to a virus and not recieve an infecting dose (inoculum). A viral dose needs to bypass your upper airway's physical barriers (mucus and cilia) to colonize cells before it can establish an infection.
The actual particle with potential to infect you is called a viron. Once a viron has managed to pass your defenses and infect you, it will begin to replicate itself exponentially while your immune system tries to catch up and stop it. In the case of something your immune system has seen before and recognises, the response will be fast. In the case of something it does not recognise, the response is slower, and the viral growth will likely outpace your immune system response for a period of time, resulting in a symptomatic infection.
The concept of initial viral load is relevant. The more virons you're exposed to and the more virons make it past your defenses, the higher the base of the exponential growth, meaning the virus establishes itself faster and in high quantities, before your immune system can react, i.e. you are more likely to experience noticeable symptoms and more likely to experience severe symptoms.
After exposure to a virus there is a wide range of possible outcomes, from the virus failing to infect you at all, to an asymptomatic infection that your immune system fights off without you ever realising you had it, to suffering a full blown infection where you will unwell for weeks.
So it is essentially a numbers game; the more you're exposed to a virus, the more likely you are to become infected and experience symptoms. Therefore, obviously, the best protection is to avoid exposure, and failing that, to limit it as much as possible. If you come across an infected person in passing, your chances are good. If you live with them and they spend several days coughing in your face, not so much.
Infection route
Generally, upper respiratory viruses only know how to infect the via the eyes and respiratory system, i.e. the nose, throat and lungs. This means you need to inhale them for them to be dangerous. Eating common cold virons is not really recommended, but chances are they'll get pulled down your throat too quickly for them to infect the cells there, and then your stomach acid will kill them. Meanwhile, inhaling air full of virons is much more likely to result in an infection.
However, getting virons on your hand leads to an easy transmission route to the nose or eyes, so hand washing is helpful.
Actionable advice
Vitamin C is commonly thought of as helpful for colds, but the science is a bit weak and doesn't ever show huge effects. High doses (approx 1g) taken at the first sign of an infection appear to reduce duration and severity, but what this means in practical terms is potentially underwhelming, e.g. I don't think most people are going to appreciate the difference between a mild cold lasting 5 days and 4.5 days. (https://pmc.ncbi.nlm.nih.gov/articles/PMC10712193/).
Vitamin D levels need to be kept high. For most people in the UK, this means supplementation of at least 10mg/100IU from at least October through to March. I think it is worth remembering that spending the majority of our time indoors is a relatively recent concept in the context of an evolutionary timescale.
Omega 3 is thought to be associated with better outcomes in severe viral cases and has reasonable theoretical basis for being so, but I'm not sure there's a lot of clinical evidence one way or the other. It is probably worth supplementing if you don't get much of it in your diet.
Protein is the building block of the immune system. Make sure you're getting enough of it, especially if you're active. If you are vegetarian, vegan or on some other restricted diet, make sure you understand what a complete protein is and ensure you're getting it.
Zinc lozenges taken in the initial stages prevents viruses from reproducing in your throat. This is supposedly quite effective, but can cause stomach upsets, so you might just end up with two problems.
Regular exercise increases baseline immune function, but heavy exercise has a suppressive effect in the short term. If you are chronically straining your body (e.g marathon training), it's worth remembering that your immune system may be poor at any given time, especially after big workouts, and act appropriately. Supplementing protein and vitamins and prioritising sleep becomes much more important for you than the average person.
Prioritise sleep, because poor sleep impairs immune function.
FFP2 masks are effective, cheap, and fairly comfortable.
An indoor humidity level in the range of about 40 - 60% is considered optimal. Dry air will reduce the effectiveness of the mucus in your airway, and moist air will cause respiratory droplets to absorb water weight and fall out of the air faster. Humidity above 60% will encourage mold, dust mites, etc.
Women have stronger immune systems, so, as I've put this under the Actionable Advice section, if you are a woman, consider remaining one, and if you aren't, then transitioning may be to your benefit, though you should probably not base your decision on this point alone (or at all). This isn't all rosy though - women are more likely to be affected by auto-immune disorders as a result of a stronger immune system.