What does mkdir -p do? specifically the "-p" part?
Have you tried running the man mkdir command in Terminal? Doing so results in the following explanation for the -p option:


  Create intermediate directories as required.  If this option is
               not specified, the full path prefix of each operand must already
               exist.  On the other hand, with this option specified, no error
               will be reported if a directory given as an operand already
               exists.  Intermediate directories are created with permission
               bits of rwxrwxrwx (0777) as modified by the current umask, plus
               write and search permission for the owner.


So basically

mkdir foo/bar/baz/quizz


will fail unless the directories foo, foo/bar and foo/bar/baz already exist.

mkdir -p  foo/bar/baz/quizz


will create any missing directories in the path (as long as you have write permissions in the parent directory) and ensure that the permissions allow you to access them.