I would recomend buying something where the codes are already available because you will not have to look for them by yourself.
Then raspberry pi just have to send the control codes to turn on/off. There a lot of tutorials online...
3. I installed on raspberry pi a web server (nginx) and made a small php script which can be called with parameters (which outlet and which status on/off) to turn on/off the power outlets. Automate flow calls the url on the web server and control devices.
It works really nice. I control watering system in the garden with automate, lights etc...