How to get category name or ID by post?

Please try below updated code

<?php
  $recent_posts = wp_get_recent_posts(array(
    'post_status'    => 'publish',
    'cat' => '',
  ));
  foreach($recent_posts as $post) : ?>
  <div class="card">
    <div class="card-bg">
      <div class="card-cat">
        <?php 
         $category_detail=get_the_category($post['ID']);//Pass POST ID
         foreach($category_detail as $cd){
         echo $cd->cat_name.'';
         } 
         ?>
      </div>
      <img class="card-img" src="https://wordpress.stackexchange.com/questions/337072/<?php echo get_the_post_thumbnail_url( $post["ID'] ); ?>">
    </div>
    <div class="card-body">
      <div class="card-title">
        <?php echo $post['post_title'] ?>
      </div>
    </div>
  </div>
  <?php endforeach;
  wp_reset_query(); ?>

Try and let me know if any query.

Hope it will help!