The regex for links that automatically gets the title of the question is as follows:
/<a href="((\S+)\/q(?:uestions)?\/(\d+)(?:|\/\S*?))">\1<\/a>/g
This of course doesn’t apply to the Markdown but to the generated HTML.
We could change the share link to match this regex, for example by adding query string: ?hack=/q/123
(it doesn't break the link).
However, there's also another requirement. The first match, after having the http://
part removed, can't contain any characters matched by this regex:
[^a-z0-9.]
that is, it can only contain lowercase letters, digits and dots. With the direct URL, the first match (after removing the http://
part) is:
stackoverflow.com
so it passes the test. With the share link, the first match is:
stackoverflow.com/a/33627846/276052?hack=
so it obviously doesn't pass.
I don't know if there's any way to make it work, but if I were you, I would just use the following Markdown to make a link:
[Difference among 'public', 'default', 'protected', and 'private'](http://stackoverflow.com/a/33627846/276052)
If you're curious about details of the process, look at the source (I cut that fragment from http://dev.stackoverflow.com/content/js/wmd.js).
Your second question has already been answered in comments by @Kendra:
Concerning your "Question 2", for the sake of the badges it won't matter. From the list of full badge descriptions: "Only clicks from outside the Stack Exchange network count towards the badge"