If you just want to merge duplicate Account then instead of writing trigger you can use Salesforce's inbuilt functionality for merging the Accounts. Just visit your Accounts at the bottom that page there is a "Tools" section in this section click on "Merge Accounts" and then you can just move ahead with Accounts you need to merge or you can visit this link where it is discussed in detail https://success.salesforce.com/answers?id=90630000000grryAAA
If you want to prevent from Entering Duplicate Records, you can use Standard Functionality Matching Rule and Duplicate Rule
These blogs will explain you step by step,
http://www.mstsolutions.com/blog/content/duplicate-management-salesforcecom
http://www.buanconsulting.com/duplicate-management-in-salesforce-com/
https://help.salesforce.com/articleView?id=managing_duplicates_overview.htm&type=0 (https://help.salesforce.com/articleView?id=managing_duplicates_overview.htm&type=0" target="_blank)
Matching Rule:https://help.salesforce.com/articleView?id=matching_rules_overview.htm&language=en_US&type=0
Duplicate Rule:https://help.salesforce.com/articleView?id=duplicate_rules_create.htm&language=en_US&release=206.5&type=0
If you have already Duplicate Records then by using This App filter it,
Try This Apps,
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000058vzKEAQ
https://appexchange.salesforce.com/listingDetail?listingId=a0N30000003IYLlEAO
Trigger to restrict after cleaning up the Duplicates,
https://success.salesforce.com/answers?id=90630000000grryAAA