With out a doubt I think that hitting 40 home runs is easier to do. Accumulating 20 wins is hard to do mostly because It may not all be your fault. You can give up one run through a game but your hitters may not score any runs. You can give your team the lead when you get taken out but the bullpen can blow it.
Many hitters have hit 40+ home runs in a season and don't get me wrong, that is still super hard, but you have control over if you hit a home run or not. You don't have control over it if you are pitching. Also your defense can make costly errors. You and your team would need to be on point all season to even get close to 20 wins.
You could also get injured and not pitch as many games so your chances are shorter. Every pitcher has bad games. Even the best of the best so you most likely have to face a loss every once in a while.
That is why I think that winning 20 games is much harder than hitting 40 home runs because it is not all up to you. It is a team that helps you win those games.