There is much less automated exchange of data than what many people assume, so the answer to your question as asked - "do they know" - is probably no. If you however ask: "can they easily find out", you must assume that the answer is yes.
In most cases, the airline is obligated to file a flight manifest with passenger data to the relevant aviation authorities and in some cases even to the immigration authorities in advance. For example, US Customs and Border Protection will always in advance be informed by the airlines about which passengers are coming and from where. If the immigration authorities do not have the information in advance, you must assume that they can get the data from the aviation authorities on demand. These records may or may not include data regarding previous connecting flights. If you however fly from A to B on one ticket from one airline and later from B to C with a separate ticket from another airline, the last airline won't know that you originally came from A and you can safely assume that there are no traces of that flight in the last flight manifest.
If a border officer is in doubt, there are however many other ways to more or less easily find out where you have been. It is nearly impossible to exist nowadays without leaving electronic traces of your whereabouts and especially if you enter your home country, border officials may very well be able to get access to this information if they require so. They don't have it when you present yourself at the immigration desk at the airport, but if you are questioned, something does not add up in your story and they find a reason to investigate further, I would consider it more than likely that the immigration authorities have legal means to request data from e.g. your bank or your cell phone provider, which show where you have been. In many cases, disclosing information about you can even be found in social networks without much effort. Posting a picture of yourself on the beach in country A and a few days later to tell an immigration officer that you haven't been there can easily go wrong.
You must also remember, that you in this case probably not only are breaking immigration laws by lying to a border official, but are (also) violating disease control legislation. The penalties for doing so can be surprising, especially if it turns out that you actually are infected with corona (which currently is an unlikely, but not unrealistic possibility when coming from Europe), lie to circumvent quarantine requirements and then with bad luck manage to infect other people.