As far as I understand it, Hungary’s populist, nativist far-right government is not really aligned with Catholicism anyway, and Catholicism does not seem to be a very important factor in Hungarian politics. For example, Hungary recently changed its laws concerning shopping on Sunday so that large shops have to close. However, this has more to do with Hungarian nationalism than it has to do with Christianity: the large shops are mostly owned by foreign companies, whereas the small shops are mostly owned by Hungarians. One must also remember that ever since the Reformation, both Catholicism and Protestantism have been important parts of Hungarian culture.
The situation in Poland is of course different, as it is the most Catholic country in Europe (with the possible exception of some very small countries that may be slightly more Catholic). Although there was considerable religious diversity in the Polish-Lithuanian Commonwealth, Catholicism has been by far the dominant religion in modern Poland. Therefore, it is not really a case of one party being aligned with Catholicism and another party being against Catholicism. That would be like saying that the US Republican Party is aligned with Christianity and the Democratic Party is anti-Christian. It is a matter of degree and emphasis. Indeed, while Lech Wałęsa was obviously always a very strong Catholic, it is believed that Wojciech Jaruzelski was also in fact a Catholic, although perhaps not openly so.
Anyway, at the end of the day, the policies with which the EU takes issue do not really have anything to do with religion. If Poland and Hungary uphold democracy and the rule of law, the EU will be happy. The UK was an EU member state until the beginning of this year, and the EU never concerned itself with our genuinely rather odd religious settlement: an established church in England, a formerly established church in Wales which retains some vestiges of establishment, a merely national church in Scotland, and formal precedence accorded to Anglian and Catholic prelates (and the Moderator of the General Assembly of the Presbyterian Church in Ireland) in Northern Ireland; Church of England prelates serving in both the upper house of legislature and the Privy Council of the whole of the UK, etc. Indeed, when Ireland joined the EEC in 1973, it was still a strongly Catholic country. Contraception was illegal in Ireland until 1980, same-sex partnerships were not recognised until 2011, abortion was illegal until 2018, and blasphemy was also illegal until 2018. The EU was evidently pretty slow in “coming for” the British and the Irish!