How to add library to Paragraph bundle using hook_preprocess_theme?
You have to do like this instead:

$variables['#attached']['library'][] = 'my_theme/my-library-name';


So you attach the library directly to $variables instead.