Auto-translated
I think a combination of Alex's and Heroist's answers is needed.
So, first of all, you need to ensure the safety of your family by sending them to country B, where everything is peaceful and calm. Then, you need to decide: what connects you to country A, besides your place of birth? What connects you to country B, besides material well-being? Is this a war for the satisfaction of some not-so-"high" interests of countries A and B, or is it a war for survival, when the aggressor country really poses a serious threat to another country and, in the more distant perspective, to other countries as well? Depending on the answer to these questions, you can participate in the war on the side of A (more likely), B (less likely), or not participate in the war at all, leaving for your family in country B.
I will add that if you decide to participate in the war, it is not necessary to do so with a rifle in your hands; you can help the front in various ways, for example, by organizing production; you need to decide where you will be more useful.
I will also add that if country A = Russia and country B = a NATO country, then you don't need to think about this dilemma at all; the war will end in a couple of hours.