hello and welcome to HCM,
The swollen tonsils have in them small holes called crypts which can cause the collection of secretions in them which can solidify to cause what we call as the tonsilolith or tonsil stone.
If this is happening frequently and since your tonsils are swollen and also since you have had episodes where you need to visit the ER, it is recommended that you undergo tonsillectomy
or the removal of the tonsils which is a simple routine surgery which can give a permanent relief and cure to all your problems
Dr Sriram Nathan