Nail pitting if few and shallow can be physiological.
It is unlikely to be related to soaps or handwashing.
However, multiple pits associated with other form of nail changes can indicate nail psoriasis. Note if there are any other unusual changes in your nails other than the pits.
Also look out for any rash on the body including the scalp.
It is advisable to have an opinion of dermatologist to look for psoriasis.
And regarding the swelling that occurs, note if it is painful or tender to touch or is there any stiffness in the morning in any joint, heel, neck or back.
The skin and joint condition can be linked, but it is difficult to say so without examination
Next Steps
If there are multiple pits (>20)/ other unusual nail changes or any skin rashes, excessive dandruff: consult a dermatologist
If the swollen areas are painful or associated with morning stiffness: consult a rheumatologist