You need to make an account on Nintendo.com, link your switch account to it, and then you can start earning points.
Digital game purchases automatically earn points. For physical games, have the game in your Switch, with the title selected, press -, select "My Nintendo Rewards Program", and then select "Earn Gold Points". That's it.
This is the part you are not going to like, you can only earn points for I believe a year after a game is released.
Gold points are credits towards digital purchases and silver you can use towards rewards on my.nintendo.com