How can getting a masters hurt PhD admissions? TL;DR:


Find myself under-qualified for PhD programs but I'm afraid getting a MS degree will hurt my chances at a better PhD program. 
U.S. based.


Longer background:


I graduated with a math degree in undergrad from a top liberal arts college. 
Two years after graduating, working, and reading some textbooks and taking a course in my longtime interest, I decided I want learn / research Natural Language Processing (AI).  
Downside: I've only taken one CS course during undergrad. I took a deep learning / natural language processing course this summer, and am taking a Data Structures/Algorithms class right now, but still I feel woefully underqualified for PhD programs.
Pros on Masters: 


It will help me shore up the missing areas in my CS education.
It will let me know if CS is something I want to do for the rest of my life.

Cons on Masters:


Certainly two years gone. 
I've heard that PhD programs often don't like MS applicants -- that they're held to a much higher standard, and that PhD programs may accept undergrads instead. 
MS is a different ballgame from PhD programs.
Many MS programs are "cash cow" programs.

Pros on PhD's 


I've published two math papers as an undergrad, and I enjoyed that experience a lot. 
Being a professor has always been a long time dream of mine, however much it may be improbable.

Cons on PhD's:


I just don't think I'll get in having taken just 1 CS course in undergrad. If I do, it likely won't be a very good program.
I'll have committed to a PhD program even though I'm sure if I want to do this or not (which I may!! But I just don't have enough exposure to know).
I don't even know if I'll be sufficiently prepared to pass my quals. 

TL;DR (after the background): Ultimately, I think I want to go to a PhD program. But I'm underprepared and want to scope out more and go to a MS program. But I'm afraid it'll hurt my chances for a better PhD program later.
If you graduated successfully from a good math program in the US, I doubt that you are under qualified for a typical doctoral program in the US. Things might be different in other places, but in the US, the normal path to a doctorate doesn't start with and MS. In fact, the early couple of years of such a program include a lot of coursework to give you the needed breadth to enable you to begin research. But programming knowledge along with algorithmics should be fine and your math background suggests you have an analytical way of thinking that isn't too different from that of most CS students. 

My suggestion would be to apply to a few doctoral programs and see what feedback you get. I doubt that what you learn in the first couple of years there will close off future options in other fields if you decide it isn't for you. But I also doubt that getting a masters will lessen your chances for later getting a doctorate at the same or a different field. 

There may be a couple of universities that favor their own students for admission to doctoral programs, but that is fairly rare. Perhaps the advice you got was from someone with experience at such a place. I don't know why Princeton comes to mind, and my information is very old, but I do associate Princeton with the idea of favoring their own. 

Doctoral study normally consists of two major hurdles. You need to pass some qualifying exams and you need to write an acceptable thesis. The coursework is mostly (not all) to get you ready for the exams. But an MS in field also does that part.