To add customer attribute programmatically in Magento 2, there are 3 basic steps which are:
1: create the setup file InstallData.php
2: create the source file
3: upgrade
Visit the following article to check the detailed procedure of adding customer attribute programmatically in Magento 2.
How to Add Customer Attribute Programmatically in Magento 2