Why can´t I dup2(p[1],1) and then write(1,buffer,1)?
You can, though it seems pointless. It would make more sense, though, if you were trying to use one of the I/O functions that writes (only) to stdout.
It only works if I do write(p[1],buffer,1) without dup2(p[1],1).
It depends on what you mean by "works". When I run your original code, the program never prints any output and never terminates, but that does not mean that the parent's writes did not successfully send data to the child.
The problem is that the child does not know when the end of the input is reached. It is waiting for an end-of-file signal on its input, which will not come as long as there are any open file descriptors associated with the write end of the pipe.
If the parent does not dupe the write end of the pipe then it has just one file descriptor open on it, and the child has one. Both close theirs at appropriate times. But in the code you present, the parent dupes p[1] onto file descriptor 1, so that it then has two open file descriptors referring to the pipe end. It only ever closes p[1], leaving file descriptor 1 open, so the child keeps waiting for more input.
The parent would close FD 1 if it exited, allowing the child to finish, but it is waiting on the child to terminate first. This is one of the more common deadlock bugs associated with I/O redirection. I'd suggest simply not having the parent dupe the file descriptor, as duping onto FD 1 unnecessarily prevents it from using its standard output for any other purpose. But if it does dupe then it must close both file descriptors before the child will terminate.