我が/わが means I or we and it can be put next to a noun to denote possession of it. So we can say わが家, which means my house or our house.

Pasted image 20250608084929.png

わがまま means my unchanged condition, but this clearly is influenced by expressions like 思いのまま or 心のまま. So this わがまま means my unchanged condition implying my will, wanting the world to go in accordance with my will, wanting the world to be 思いのまま, 心のまま.