How to get notification when Actor is selected in Editor?

For some reason this code seems to run twice. Any idea why this can happen?
I’m using is in a UObject inside an editor plugin.