What is the functionality of
setProcessDefinitionNameOrId method in
This method is used to specify that current record will be submitted to which procress. If one object have multiple approval process and many of them does not match criteria then you will get an exception if you try to submit your record in them. To over come this its better if you specify your particular process to handle the request.
As per Salesforce docs
The process definition developer name or process definition ID. The record is submitted to this specific process. If set to null, submission of a record approval follows standard evaluation; that is, every entry criteria of the process definition in the process order is evaluated and the one that satisfies is picked and submitted.