Practice of redirecting to your own page has been started long time for 2 main reasons:

 1. Adding link click counter in your own PHP code so you can track how many people clicked on the link
 2. Preventing your domain from having too many outbound links 

If your website has too many outbound links directly on the page it may affect your SEO although Google algorithm is much better than 10 years ago and if you have 1 link per article or so I don't think it will have any negative impact.

There is also psychological factor and not many people speak about it, a visitor of the page seeing ?ref=122345, if he knows it's am affiliate link he may suspect that your article is not genuine and that you are doing this only for money. For that reason people preferred to hide the fact that article is sponsored or that they have any advantage of recommending a product or service.

There is nothing bad an attacker could do if he saw your affiliate link.