Does Mysql locks table while insert operation
InnoDB will only lock the row.  But it will eventually have to update all the indexes; however this is mostly deferred.

Was something else going on while the INSERT was taking 36 seconds?  Perhaps a SELECT ... FOR UPDATE?  Or even a SELECT can block the INSERT in certain circumstances.

Next time it happens, quickly do SHOW FULL PROCESSLIST to see what else is running.  Then do SHOW ENGINE InnoDB STATUS to (hopefully) get some info specific to the INSERT and why it is blocked.

What version are you running?  Newer versions have tables to help get more info, even after the fact.