Loop corrections to soft theorems in gauge theories and gravity