The OED gives one meaning of "against" as "Indicating a thing to which reference is made in order to verify or measure something else." (9c). This is a specific example of a general meaning where something is put next to something: "Connecting two quantities compared or opposed to each other, such as numbers of votes, scores, percentages, etc." (9b) It is as if you were writing the two things next to each other in a ledger or record book.
In this specific case, I assume a phone number must be connected with an ID number indicated by an ID card (for instance when you buy a phone or have a phone line connected). To say "a phone number is registered against an ID card" means that each phone number is associated with some ID. In "How to check all the phone numbers registered against your identity card", the instructions are to find all phone numbers connected to a specific ID card/number.
A similar real world example is (from hospital statistics documentation): "The clinician ... should be recorded against the corresponding operation". This is a case of putting a name against a (medical) operation. (Recorded and registered being near-synonyms.)
It also closely relates to the meaning of "against" in finance: "Indicating an asset which forms the basis of a financial activity". Here, a loan or debt is set off against an asset, again in a ledger. I found an example of this: "The Check will tell you whether a vehicle you are looking to buy has any outstanding insurance interest recorded against it".
Other prepositions would work fine: to or with. But against is also OK, and maybe sounds a bit more formal or businesslike in this example (as in the clinical example I quoted), giving the person's "How to" a more authoritative air.
Reference: "against, prep., conj., adv., and n." OED Online, Oxford University Press, December 2022, www.oed.com/view/Entry/3754. Accessed 18 January 2023.