if you want to gain/lose weight the only thing you need is a calorie surplus/deficit, as long as you are in a calorie surplus/deficit you will lose weight.
If you want to gain weight you should aim to gain lean body mass. You should eat regularly and eat everything you have on your plate, no skipping meals, no leaving food behind, use bigger bowl/plates, so the amount of food would seem small, and eat quickly so you wouldn't get too full too fast. You should get enough protein (1.5g per kg of body weight is enough) and strength train, you can use your own body weight, but if you can easily do more than 30 reps it's junk volume and you should add weights like a water jog in backpack or something similar . Don't create a surplus greater than 500 since it will turn into fat, and get 7-9 hours of sleep. You also should eat cholesterol and fat in general to produce testosterone and other hormones, aim for 0.5-1g of fat per kg of your body weight. The macro split doesn't matter, you don't have to eat in 60/25/15 or any other numbers, as long you hit your protein and fat goals you can fit the rest of calories with whatever you want, but you should get starchy carbs like rice and bread since they will fuel your workouts and make them smoother
Losing weight is easier but takes longer. The only thing you need is to be in a calorie deficit, but if you will create a deficit of 1000 and more you will fall off tracks after a couple of months since you will be extremely hungry. You should aim to lose 0.5%-1% of your body weight per week, you will lose the number on scale rapidly in the first month because you will lose a ton of water, but it will stabilize over time. If you want to preserve your muscle mass you should eat enough protein (2g of protein per kg of LEAN body mass), strength train and get enough sleep. You won't gain as much muscle mass as someone who is bulking. You shouldn't be afraid of fats, you need them for brain functioning and hormone production. You should get 0.5g-1g of fat per kg of your LEAN body mass
You can calculate your body fat % with this site:
https://www.bizcalcs.com/body-fat-navy/You can calculate your calories with this site:
https://www.sailrabbit.com/bmr/ (use katch mcardle (hybrid) formula)