In addition to what you're getting from that query, include the xact_start and state_change columns from pg_stat_activity. My guess is that your code is starting a transaction, then running a query, then processing the query results before committing the transaction. Since query locks are held for the duration of the transaction, this will cause the locks to be held for a long time if the processing step takes a while.
Actually each of this transaction is just single INSERT or single UPDATE query.
If that turns out not to be the problem, then you'll probably need to provide a bit more detail before anyone will be able to provide a better answer. I mean, I'm even guessing that it's an app making the queries.
Can you let me know what exact details should be provided here?