Yes. You have a good understanding of Anapana.
You asked: “Are the following ways the correct way to do Anapana:
1) If I have an immoral thought, replace with moral good thought?
2) If I do immoral speech, replace with moral speech?
3) If I do an immoral bodily action, replace with a meritorious deed?”
Exactly right.
“4) For immoral speech and immoral bodily action, is it ok to replace them with good moral thoughts like a “may you always be safe” instead of replacing them with a moral speech and moral bodily action?”
Yes. That is a good start.
– As you do that, you will see that it is also good to engage in moral speech and moral deeds.
– Moral speech includes not only speaking kind words but also explaining to Dhamma to others or giving any kind of advice that can be helpful to others. See, “Right Speech – How to Avoid Accumulating Kamma”
– Moral deeds include giving to those who are in need, helping out those in need, etc (acts of kindness).
It is also necessary to stop associating with people with bad character and associate with people with good character: “The Law of Attraction, Habits, Character (Gati), and Cravings (Asavas)“