WPDB SQL query with prepare() returning variable, not db value

The function bbp_forum_id() will directly echo its value, you want to use bbp_get_forum_id() which will return the value for use in the context of an API call.