How to add javascript with #attached in a node which contains a specific paragraph bundle
Try this code for attaching

$variables['#attached']['js'][] = 'myfile.js';


Or

$variables['#attached']['library'][] = 'myfile.js';