It is one of those things that Sonar have decided to do automatically when you start Sonar. Here is the info from page 232 from the X2 ref manual
Local control
You should normally disable the Local Control setting on your master keyboard to prevent notes from being doubled when you play your keyboard. If you disable Local Control, your keyboard sends notes that you play to SONAR, which echoes them to the synthesizer, which plays them only once.
When SONAR starts, you can have it send a special MIDI message that attempts to disable Local Control automatically. Most modern synthesizers respond to this message. If yours does not, you will need to disable Local Control every time you turn it on for use with SONAR.
To automatically disable all local control whenever you launch SONAR
1. In the directory where SONAR is installed, double-click on the TTSseq.ini file to open it.
2. In the [Options] section, add the line:
SendLocalOff=1
3. Save the file and close it.
4. When you launch SONAR, it automatically sends a Local Off message to your keyboard.
Note: Not all keyboards respond to Local Off messages.
You need to change the SendLocalOff value to 0 instead.
This used to annoy me as well. I think as long as you do know that you will get note doubling being on a track routed back to itself. You can also stop it by simply not using midi thru mode. You can still hear your synth
(due to local control being ON) and record its output midi data.
If you are using that same synth to control other synths or VST's then you need local control off so you don't hear it but that is a time to do it manually.