I believe that was a goal for a future date that has not yet arrived. Trump complained about it, but it wasn't due yet and was going to happen anyway. So it can look like he made it happen. He's full of cons.
The 2% commitment was originally agreed to in 2006. After member nations continued to fail to spend enough, in 2014 it was a set as a goal to increase towards that goal year over year until 2024: