Searching for new physics from SMEFT and leptoquarks at the P2 experiment