Surgery can be part of the gender expression and physical transition of people with nonbinary gender identities. Some nonbinary people call themselves transsexual and seek surgery, and some don't. A nonbinary person doesn't need to have or want surgery in order for their gender identity to be valid. This is true for transgender people of all kinds. For those nonbinary people who take a physical transition (and not all nonbinary people do), surgery is one option on their transition path. For some of those who do, gender dysphoria and body dissonance can make it so that they need physical transition and surgery. In that case, these can be life-saving procedures that are medically necessary.
For transgender people of all kinds, there are two main kinds of gender-validating surgeries: top surgery means any kind of surgery done on the chest or breasts, while bottom surgery means any kind of surgery on the reproductive organs or genitals. In addition to these two kinds, there are many more kinds of surgery that a person can see as gender-validating surgeries. For example, those to change the shape of the face, change the voice, remove fat from certain parts of the body, and so on.