I'm going to write a hook to distinguish a saved membership record, how do I know the last action of saved membership record is edit or renewal?
CiviCRM keeps track of membership changes in civicrm_membership_log table for all changes to membership attributes like start date, end date, status. But it will pretty difficult for you to guess if the membership is actually being renewed or updated unless you perform some more checks with different log entries from civicrm_membership_log table.
The other and most easiest/convenient way to know renewal or status change is through Activities. CiviCRM create different activities for membership when a membership is added, renewed and status/type is changed etc(see in attached image list of Activity types for membership). So it will be easy to use post or pre hook on Activity to guess the context.
CiviCRM keeps log tables that document changes to core tables like
civicrm_membership. They're all prefixed
log_, so in this case you could look for the newest row in
log_civicrm_membership for the relevant
id being the membership ID from the core table).
That might contain enough data to help you distinguish between the two cases you describe.