How to merge overlapping time intervals if the interval not more than 4 minutes in PostgreSql
As I mentioned in my comment, your request is not well defined because it is unclear how the 4-minute wide time windows are supposed to be chosen.
In addition, the nature and importance of the id column is unclear.
Be that as it may, I came up with the following query. It uses window functions in order to define the group edges, and then filters out any row that is not an edge:
WITH t AS (
    SELECT id, action, date
         , min(date) OVER (PARTITION BY round(extract(epoch FROM date)/240)) min_date
         , max(date) OVER (PARTITION BY round(extract(epoch FROM date)/240)) max_date
    FROM tab
)
SELECT id, action, date
FROM t
WHERE date = min_date OR date = max_date;