Additional SQL Server features and topics not covered by specific categories
I discovered that the login on the other node has a different SID compared to the database user. Could this be the reason?
Yes, that is the reason. Mapping between login on server level and user on database level is by SID, not by name. This is mainly an issue with SQL logins, since Windows logins get their SID from the AD.
The remedy is to drop the login on the secondary and create it, using the SID option:
CREATE LOGIN NisseNils WITH PASSWORD = 'Top$ecret!', SID = 0x....
You get the SID value from what's on the primary.