Your crank bolts loosened or weren't tight enough, the square hole in the soft alloy crank became deformed by the hard steel spindle, and once that happens the cranks will never stay tight. Time for new cranks. Different cranks can have slightly different spacing of the chainring. Be prepared to fiddle with the chainline.