I would like to know if we can eat the food prepared or touched by Christians or Jews (whether they drink alcohol and eat pork or not)And under what situations can we consume their food? and after consuming, how can we purify ourselves?is it true that our hajat are not accepted for 40 days after consuming such food?

The Ahlul Kitab (that is, the Jews, the Christians and the Zoroastrians) are ritually pure (tahir) as long as you do not know that they have become ritually impure (najis) by coming into contact with an impure object. You can follow this ruling when dealing with them.
As long as it is not known that the hands of the cook were najis, the food is to be considered tahir.
A Muslim is allowed to eat the food prepared by a non-Muslim who is not from Ahlul Kitãb [for example, a Hindu or a Buddhist], provided that he does not know or is not sure that the non-Muslim touched the food with wetness; and provided that he does not know or is not sure that the food consists of what is forbidden to him like intoxicating drinks. As for meat, fat and their extracts, the food cooked by non-Muslims should not contain any of these. If the food contains meat and animal fat, he should be sure that they are halal .