You've failed to take into account that the Protoss can just cancel their building and start a new one, so you wasted all that mining time (attacking with SCVs) whereas they only wasted 25 minerals. Unless you are talking about attacking a building that is already fully built... in which case, is also a bad idea because he will probably be building cannons next to that completed pylon, and will have most likely walled you off (with other incomplete structures) from being able to actually attack it.
Attempting to actually kill a probe (with SCVs) that is doing circles around your base is a complete waste of time, takes about 2 minutes to finally kill it, meanwhile he will just bring another one to your base. That said, at least 1 worker following the probe will at least force him to keep the probe on the move, somewhat limiting choices for placement.
My best defense so far has been good scouting, walling in most games, and dropping 1-2 bunkers as soon as I see the cannons going up.
You may also try to put workers in likely build places to physically block the Protoss player from walling off their cannons at your mineral line, but this takes some experience.