How knowledgable do I have to be when I start a phd? Say I wish to pursue a phd in some CS related field. How knowledgable do I have to be in the field I am pursuing? I'm asking because some things happened recently that led me to doubt myself:

I have been doing some machine learning research for the past year and I'm working towards a first author conference submission (as an undergrad). As I was drafting my paper, my professor asked some questions about the project I'd done - such as why I chose certain methods over others, or why I choose a particular parameter for my experiments and more. And I realised that I couldn't answer them. See, in my project, I didn't create anything new. I simply took existing methods and applied them to a relatively unexplored research area, which means that I was just following what other people did. To take something and apply it somewhere else doesn't really require that much knowledge in my opinion. I've been reading papers, trying to explain why some methods outperform others and often times I do not fully understand them. The high level logic maybe I understand, but certainly not the in-depth algorithms or implementations.

I feel as if I know nothing about this field (and I probably really don't know much). Yet, my professor offered me a phd position. I feel like he was placing too much confidence in me. Have I managed to fluff my way through this project, or is this something that happens to other people too? Especially those who completed their bachelors and went for a direct phd.
It is very appreciated for your honesty. In my knowledge, I have seen many students they join PhD courses having very little knowledge in their field. Also, many join in new fields without having any proper/concrete ideas. However, their interest to learn, hard work and self confidence all together help them to achieve a PhD and a great career ahead. It is also worth to mention that each PhD student must face lots of ups and downs. However, their self confidence and interest to do something new helps to overcome all the down situations. 

So first of all, you should never loose your self confidence at the very beginning. It is very well said that "it is never too late to start". You will get enough time in PhD to learn many new things including your objectives. Moreover, it seems you have got a very good and inspirational professor. So there is no doubt whatever knowledge you have now, it is very much enough to pursue a PhD in your area of interest. Good Luck!!