when detaching a database sqlserver checks if there are changes suchs as updates and inserts that were processed but has not (yet) actually done. The changes reside in memory of sqlserver but were not written to the disk. So I think it does these first prior detaching.
Detaching can take a while, because of the need to "flush the log", etc. It seems to me that the GUI provides a checkbox to skip that step, but that is needless risk from my perspective.
I can't think of a reason that attaching a database would take more than a minute or so (basically modify a few system tables, then go through the normal database recovery/startup that happens whenever a database is first opened).