Your issue is nothing to do with ExpressionEngine.
You can fix this a number of ways, but how very much depends on what else you are doing on the page. But you might get some ideas for a way to proceed from other discussions on stackeexchange of the issue - e.g. look at the notes to the first answer to this question - https://stackoverflow.com/questions/14804941/how-to-add-smooth-scrolling-to-bootstraps-scroll-spy-function
More generally, EE is a powerful back-end CMS that gives you total control over how the information is displayed within your website. The upside of this is flexibility, the downside is that for the most part you have to create your own templates to control what HTML is generated; but within these templates your control over how an anchor tag is created is complete. In the light of this, your final question does not make much sense. Perhaps if you clarified what you are trying to do you might get a better answer.