for gyms and raids you just take 6 pokémon and mash the screen as fast as you can until you beat the other pokémon, and then if it's a gym you can put 1 in to defend and earn coins every day, or if it's a raid you can attempt to catch it
the battling is pretty shallow and you get the best success by just mashing the special attack button so it uses it as soon as it's up
gym defending pokémon get weaker every time you beat them, when they get to 0cp they are knocked out of the gym (i feel like the most i've ever had to fight the same pokémon in a gym is 4 or 5 times before it was knocked out), when there's nothing left in the gym you can take it for your team and put a defender in yourself. then you get (up to) 50 coins when it is knocked out itself.
you can't attack a gym owned by the same team as yourself, but if there are less than 6 pokémon in it, you can put a defender of your own in since it's your team anyway. if it's owned by your team and there are 6 in there, tough luck nothing you can do until it's taken by another team.
you probably can't solo anything above level 2 with regards to raids (maybe lvl 3 if you have a really strong, super effective team) so don't waste a raid pass on anything over that since you only get 1 free one a day