In a domestic setting it is made by a boiler starved of oxygen, it became a problem in the 70's and 80's when double glazing started to be a thing and houses became more sealed. Up to that point boilers and particularly "geyser type" water heaters like the Ascot drew air from the room.
As the rooms were more sealed with less fresh air the boilers didn't have enough air to make CO2 and instead made CO. Ascot rapid water heaters, common once in bathrooms and kitchens used a lot of gas very quickly, and drawing a bath without the right ventilation could make enough CO to kill, and it did, on many occasions.
So called "open flue" appliances were banned, all gas boilers and water heaters installed in the home are now BALANCED FLUE, meaning they draw air from outside and have no air or gas passage into the home.
The Ascot water heater, invented in the late 1800s by Johannes Vailant lives on as the basis for the modern combi boiler, water being heated quickly, on demand , as it is drawn, modern boilers like the Ascot before them, burn a lot of gas for a short period so can in theory produce a lot of CO quickly
In theory if they are fitted properly and working properly CO cannot get into the home, but if it does, being odourless it can kill quickly, it makes you quite drowsy which is another risk inherent to it.
Natural gas from the main has a smell added, it too is very dangerous if it escapes, whilst it can suffocate, its main risk is that in the right ratio with air it is highly explosive, you occasionally see a house completely destroyed by a gas explosion.