torch.autograd.grad will returns your gradients in a tuple. Which for a single gradient Tensor will be like what you have above
(tensor([[-19.5000, -19.5000],
[-19.5000, -19.5000]]),)

(A Tensor wrapped inside brackets with a comma at the end.)
However, when you add [0] at the end of d_loss_dx = grad(outputs=loss, inputs=x)[0], you’re telling PyTorch to return the 0th element of that tuple which in your case is the tensor within it, i.e.,
tensor([[-19.5000, -19.5000],
[-19.5000, -19.5000]])

I hope that makes sense?
You can get similar behaviour without adding [0] at the end by placing a comma after your d_loss_dx variable, i.e.,
d_loss_dx,  = grad(outputs=loss, inputs=x)

will return
tensor([[-19.5000, -19.5000],
[-19.5000, -19.5000]])