Turn the Instant Pot to the saute function and melt the butter (or heat oil). Add the onion and cook for about 1 minute. Add garlic and spices, stirring to combine. Add the beans and vegetable stock; turn off the saute function. Cover with lid and make sure it's set to sealing. Cook on high pressure for 36 minutes. Let the pressure release naturally (~20 minutes).
If needed, remove some of the remaining liquid. When I decide to remove some liquid, I reserve it and add back in as needed. The beans do soak it up once you start mashing them. Using a potato masher or immersion blender, mash beans to desired consistency (I like some texture so I don't make them completely smooth).
Serve as desired. Store in an airtight container in the fridge for up to 5 days.
Notes
If you want to quick release the pressure, set the cooking time to 40 minutes.